package com.ktjy.goods.controller;

import com.ktjy.base.R;
import com.ktjy.goods.feign.FeignRealTimeService;
import com.ktjy.goods.service.RealTimeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * RealTimeController 第三方实时接口
 *
 * @author LILIBO
 * @since 2025-02-18
 */
@Tag(name = "实时接口", description = "实时接口")
@RestController
@RequestMapping("/realtime")
public class RealTimeController {

    /**
     * 编程式远程调用服务
     */
    @Resource
    private RealTimeService realTimeService;

    /**
     * OpenFeign声明式远程调用服务
     */
    @Resource
    private FeignRealTimeService feignRealTimeService;

    /**
     * 实时天气
     *
     * @param city 城市
     * @return R 实时天气
     */
    @Operation(summary = "实时天气")
    @GetMapping("/weather")
    public R weather(@Parameter(description = "城市") @RequestParam(required = false) String city) {
        // 使用编程式远程调用服务
        // Object weather = realTimeService.weather(city);
        // 使用OpenFeign声明式远程调用服务
        Object weather = feignRealTimeService.weather(city);
        return R.success(weather);
    }

}
